import * as _ from "lodash"
import * as app from "./app"
import * as browsing from "./browsing"
import * as captcha from "./captcha"
import * as cart from "./cart"
import * as catalog from "./catalog"
import * as checkout from "./checkout"
import * as customer from "./customer"
import * as data from "./data"
import * as district from "./district"
import * as follow from "./follow"
import httpClient from "./httpclient"
import * as identity from "./identity"
import * as marketing from "./marketing"
import * as message from "./message"
import * as order from "./order"
import * as payment from "./payment"
import * as security from "./security"
import * as shipping from "./shipping"
import * as storage from "./storage"
import * as store from "./store"

export * from "./analytics"

export {
  app,
  browsing,
  captcha,
  cart,
  catalog,
  checkout,
  customer,
  data,
  district,
  follow,
  marketing,
  message,
  order,
  payment,
  security,
  shipping,
  store,
  storage,
  identity,
}

export interface Configuration {
  urls: string
}

export function configure(config: Configuration) {
  if (_.has(config, "urls")) {
    httpClient.defaults.baseURL = _.endsWith(config.urls, "/") ? config.urls.substring(0, config.urls.length - 1) : config.urls
  }
}
